package com.app.adapter;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.app.activity.R;
import com.app.adapter.ADlistAdpter.ViewHolder;

public abstract class ADBaseAdpter extends BaseAdapter {
	protected  Activity activity ;
	protected ArrayList<ADScheduleAdpterItem> items  = new ArrayList<ADScheduleAdpterItem>();
	public ADBaseAdpter(Activity activity)
	{
		this.activity = activity;
	}
	public Activity getActivity() {
		return activity;
	}

	public void setActivity(Activity activity) {
		this.activity = activity;
	}
	
	
	
	public View viewWithItem(ADScheduleAdpterItem item)
	{
		LinearLayout contentview = new LinearLayout(activity);
		TextView leftTextView = new TextView(activity.getApplicationContext());

		leftTextView.setText(item.getLabel());

		leftTextView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);

		leftTextView.setTextColor(Color.BLACK);
		leftTextView.setHeight(60);

		LinearLayout.LayoutParams lefttxt = new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.FILL_PARENT,
				LinearLayout.LayoutParams.FILL_PARENT);
		contentview.setOrientation(LinearLayout.HORIZONTAL);
		contentview.addView(leftTextView, lefttxt);
		if (item.getType() == item.ITEM_SELECT) {
			leftTextView.setWidth(160);
			TextView rightTextView = new TextView(activity
					.getApplicationContext());
			rightTextView.setText(item.getValue());
			rightTextView.setWidth(160);

			rightTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);

			rightTextView.setTextColor(Color.BLACK);
			rightTextView.setHeight(60);
			contentview.addView(rightTextView, lefttxt);
		} else if (item.getType() == item.ITEM_INPUT) {
			leftTextView.setWidth(120);
			EditText editText = new EditText(activity.getApplicationContext());
			editText.setHint(item.getValue());
			editText.setWidth(180);
			// editText.setHeight(40);
			contentview.addView(editText);
		} else if (item.getType() == item.ITEM_DATE) {
			leftTextView.setWidth(160);
			TextView rightTextView = new TextView(activity
					.getApplicationContext());
			rightTextView.setText(item.getValue());
			rightTextView.setWidth(160);

			rightTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);

			rightTextView.setTextColor(Color.BLACK);
			rightTextView.setHeight(60);
			contentview.addView(rightTextView, lefttxt);
		}
		contentview.setMinimumHeight(60);
		return contentview;
	}
	
}
